﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace nGSO.KnapsackProblem
{
    public class KpConfigElement : ConfigurationElement
    {
        public int[] Weights
        {
            get 
            {
                return EncodedWeights.Split(',').Select(s => int.Parse(s)).ToArray();          
            }
        }
        public int[] Costs
        {
            get
            {
                return EncodedCosts.Split(',').Select(s => int.Parse(s)).ToArray();
            }
        }

        public int Dims
        {
            get
            {
                return Costs.Count();
            }
        }

        [ConfigurationProperty("TestSetName")]
        public string TestSetName
        {
            get
            {
                return (string)this["TestSetName"];
            }
            set
            {
                this["TestSetName"] = value;
            }
        }
        [ConfigurationProperty("EncodedCosts")]
        public string EncodedCosts
        {
            get
            {
                return (string)this["EncodedCosts"];
            }
            set
            {
                this["EncodedCosts"] = value;
            }
        }
        [ConfigurationProperty("EncodedWeights")]
        public string EncodedWeights
        {
            get
            {
                return (string)this["EncodedWeights"];
            }
            set
            {
                this["EncodedWeights"] = value;
            }

        }
        [ConfigurationProperty("MaxCapacity")]
        public int MaxCapacity
        {
            get
            {
                return (int)this["MaxCapacity"];
            }
            set
            {
                this["MaxCapacity"] = value;
            }
        }
        [ConfigurationProperty("TestCount")]
        public int TestCount
        {
            get
            {
                return (int)this["TestCount"];
            }
            set
            {
                this["TestCount"] = value;
            }
        }
        [ConfigurationProperty("OptimizedCost")]
        public int OptimizedCost
        {
            get
            {
                return (int)this["OptimizedCost"];
            }
            set
            {
                this["OptimizedCost"] = value;
            }
        }
        [ConfigurationProperty("LuceferinInitialValue")]
        public int LuceferinInitialValue
        {
            get
            {
                return (int)this["LuceferinInitialValue"];
            }
            set
            {
                this["LuceferinInitialValue"] = value;
            }
        }
        [ConfigurationProperty("DecisionRange")]
        public double DecisionRange
        {
            get
            {
                return (double)this["DecisionRange"];
            }
            set
            {
                this["DecisionRange"] = value;
            }
        }
        [ConfigurationProperty("UpdateDecisionRange")]
        public double UpdateDecisionRange
        {
            get
            {
                return (double)this["UpdateDecisionRange"];
            }
            set
            {
                this["UpdateDecisionRange"] = value;
            }
        }
        [ConfigurationProperty("NeighbourhoodThreshold")]
        public int NeighbourhoodThreshold
        {
            get
            {
                return (int)this["NeighbourhoodThreshold"];
            }
            set
            {
                this["NeighbourhoodThreshold"] = value;
            }
        }
        [ConfigurationProperty("StepSize")]
        public double StepSize
        {
            get
            {
                return (double)this["StepSize"];
            }
            set
            {
                this["StepSize"] = value;
            }
        }
        [ConfigurationProperty("UpdateLuceferingValue")]
        public double UpdateLuceferingValue
        {
            get
            {
                return (double)this["UpdateLuceferingValue"];
            }
            set
            {
                this["UpdateLuceferingValue"] = value;

            }
        }
        [ConfigurationProperty("DissipationOfLuceferin")]
        public double DissipationOfLuceferin
        {
            get
            {
                return (double)this["DissipationOfLuceferin"];
            }
            set
            {
                this["DissipationOfLuceferin"] = value;
            }
        }
        [ConfigurationProperty("Iterations")]
        public int Iterations
        {
            get
            {
                return (int)this["Iterations"];
            }
            set
            {
                this["Iterations"] = value;
            }
        }
        [ConfigurationProperty("Agents")]
        public int Agents
        {
            get
            {
                return (int)this["Agents"];
            }
            set
            {
                this["Agents"] = value;
            }
        }

        public override bool IsReadOnly()
        {
            return false;
        }
    }
}
